﻿var EARTH_RADIUS = 6378000.137;

var dmgis = dmgis ? dmgis : {};
dmgis = (function () {
})

dmgis.enum = dmgis.enum ? dmgis.enum : {};
dmgis.enum = {
	DMGISTileType: {
		Service: 1,//地图服务发布瓦片
		Publish: 2//直接发布瓦片文件夹
	},

	GaodeType: {
		VEC: 1,//矢量图（含路网、含注记）
		VEC0: 2,//矢量图（含路网，不含注记）
		IMG: 3,//影像底图（不含路网，含注记）
		IMG0: 4,//影像底图（不含路网、不含注记）
		RIMG: 5,//影像路图（含路网，含注记）
		RIMG0: 6//影像路网（含路网，不含注记）
	},

	BaiduType: {
		VEC: 1,
		IMG: 2
	},

	TiandituType: {
		VEC: 1,//矢量地图
		CVA: 2,//矢量标签
		IMG: 3,//影像地图
		CIA: 4,//影像标签
		TER: 5,//地形图
		CTA: 6//地形标签
	}
}

dmgis.object = dmgis.object ? dmgis.object : {};
dmgis.object = (function () { })

dmgis.object.Point = (function (numX, numY) {
	this.x = numX;
	this.y = numY;
})

dmgis.object.Envelope = (function () {
	this.minx = 8176078.237521;
	this.miny = 465041.899497;
	this.maxx = 15037685.885628;
	this.maxy = 7326649.547604;
	this.getWidth = getWidth;
	this.getCenter = getCenter;
	this.getWidth = getWidth;
	this.getHeight = getHeight;
	this.scale = scale;
	this.init = init;
	this.initenv = initenv; //初始矩形
	this.makeFromCenter = makeFromCenter;
	this.initextent = initextent;

	function getWidth() {
		return this.maxx - this.minx;
	}

	function getHeight() {
		return this.maxy - this.miny;
	}

	//缩放矩形
	function scale(factor) {
		this.makeFromCenter(this.getCenter(), this.getWidth() * factor, this.getHeight() * factor);
	}

	//得到中心点
	function getCenter() {
		var dblCenterX = this.minx + this.getWidth() / 2;
		var dblCenterY = this.miny + this.getHeight() / 2;
		return new dmgis.object.Point(dblCenterX, dblCenterY);
	}

	//中心点设置矩形
	function makeFromCenter(center, width, height) {
		this.minx = center.x - width / 2;
		this.maxx = center.x + width / 2;
		this.miny = center.y - height / 2;
		this.maxy = center.y + height / 2;
	}

	//初始矩形
	function init(env) {
		this.minx = env.minx;
		this.miny = env.miny;
		this.maxx = env.maxx;
		this.maxy = env.maxy;
	}

	function initextent(extent) {
		this.minx = extent[0];
		this.maxx = extent[2];
		this.miny = extent[1];
		this.maxy = extent[3];
	}

	//初始矩形
	function initenv(minx, miny, maxx, maxy) {
		if (minx < maxx) {
			this.minx = minx;
			this.maxx = maxx;
		} else {
			this.minx = maxx;
			this.maxx = minx;
		}
		if (miny < maxy) {
			this.miny = miny;
			this.maxy = maxy;
		} else {
			this.miny = maxy;
			this.maxy = miny;
		}
	}
})

dmgis.object.SpatialQuery = (function () {
	this.strSql = "dmgis_id>0"; //查询条件
	this.env = null; //查询矩形范围i  矩形和多边形只能用一个
	this.strPos = null; //查询多边形范围  子多边形之间用*号  244 244;345 345;645 543*343 321;334 765;432 321
	this.init = init;
	this.GetXmlString = GetXmlString;

	function GetXmlString() {
		var sAXLText = "<SPATIALQUERY>";
		if (this.strSql != null && this.strSql.length > 1) {
			this.strSql = this.strSql.replace("<", "%%");
			sAXLText = sAXLText + '<QUERY where="' + this.strSql + '"/>';
		}
		if (this.env != null) {
			sAXLText = sAXLText + '<ENVELOPE maxy="' + this.env.maxy + '" maxx="' + this.env.maxx + '" miny="' + this.env.miny + '" minx="' + this.env.minx + '"/>';
		}
		if (this.strPos != null && this.strPos.length > 1) {
			sAXLText = sAXLText + '<POLYGON coords="' + this.strPos + '"/>';
		}
		sAXLText = sAXLText + "</SPATIALQUERY>";
		return sAXLText;
	}

	function init(svr) {
		this.strSql = svr.strSql;
		this.env = null;
		if (svr.env != null) {
			this.env = new dmgis.object.Envelope();
			this.env.init(svr.env);
		}
		this.strPos = svr.strPos;
	}
})

dmgis.object.Chartvalue = (function (lookupfield, outlineclr, outlinewid, strcolor) {
	this.lookupfield = lookupfield; //字段名
	this.outlineclr = outlineclr; //外框颜色
	this.outlinewid = outlinewid; //外框宽
	this.strcolor = strcolor; //颜色
})

dmgis.object.Tm = (function () {
	this.type = 1; //专题图的类型 0直方图 1饼图
	this.Barkd = 20; //直方图的宽度
	this.Barhd = 10; //直方图的厚度
	this.Barfx = 0; //直方图的方向
	this.Minsize = 0;
	this.Maxsize = 50; //图屏幕的大小
	this.Minvalue = 0;
	this.Maxvalue = 500; //图显示数据的大小
	this.Transparency = 0; //是否透明 1透明 0不透明
	this.Pie = 0; //饼图是否为半圆
	this.tmFieldSet = new Array(); //专题图字段(为Dmchartvalue数组)
	this.GetXmlString = GetXmlString; //得到xml
	this.AddTmField = AddTmField; //添加专题字段
	function GetXmlString() {
		var sAXLText = '<CHARTSYMBOL type="' + this.type + '" minsize="' + this.Minsize + '"';
		sAXLText = sAXLText + ' minvalue="' + this.Minvalue + '" maxsize="' + this.Maxsize + '"';
		sAXLText = sAXLText + ' maxvalue="' + this.Maxvalue + '" transparency="' + this.Transparency + '"';
		sAXLText = sAXLText + ' pie="' + this.Pie + '" barfx="' + this.Barfx + '" barhd="' + this.Barhd + '" barkd="' + this.Barkd + '" >';
		var num = this.tmFieldSet.length;
		for (var i = 0; i < num; i++) {
			sAXLText = sAXLText + '<CHARTVALUE lookupfield ="' + this.tmFieldSet[i].lookupfield + '" outline ="' + this.tmFieldSet[i].outlineclr + '" outlinewid="' + this.tmFieldSet[i].outlinewid + '" color="' + this.tmFieldSet[i].strcolor + '"  />';
		}
		sAXLText = sAXLText + "</CHARTSYMBOL>";
		return sAXLText;
	}

	function AddTmField(lookupfield, outlineclr, outlinewid, strcolor) {
		var len = this.tmFieldSet.length;
		this.tmFieldSet.push(len);
		this.tmFieldSet[len] = new dmgis.object.Chartvalue(lookupfield, outlineclr, outlinewid, strcolor);
		return true;
	}
})

dmgis.object.HighDisp = (function () {
	this.type = 0; //高亮的类型    (3 为假，0为查询 1索 2号)
	this.isNod = 0; //高亮是否为节点
	this.strHighIndexSet = "569,562"; //高亮索引实体集合字符  1，2，3，4
	this.strHighIDSet = null; //高亮实体号集合字符   1，2，3，4
	this.sqlHigh = new dmgis.object.SpatialQuery(); //高亮的条件  SpatialQuery
	this.GetXmlString = GetXmlString;

	function GetXmlString() {
		var sAXLText = "";
		if (this.type == 0) {
			sAXLText = '<DISPHIGH type="' + this.type + '"  objtype="' + this.isNod + '">';
			sAXLText = sAXLText + this.sqlHigh.GetXmlString();
			sAXLText = sAXLText + "</DISPHIGH>";
		} else if (this.type == 1) {
			sAXLText = '<DISPHIGH type="' + this.type + '"  objtype="' + this.isNod + '">';
			sAXLText = sAXLText + '<INDEXLIST list="' + this.strHighIndexSet + '"/>';
			sAXLText = sAXLText + "</DISPHIGH>";
		} else if (this.type == 2) {
			sAXLText = '<DISPHIGH type="' + this.type + '"  objtype="' + this.isNod + '">';
			sAXLText = sAXLText + '<IDLIST list="' + this.strHighIndexSet + '"/>';
			sAXLText = sAXLText + "</DISPHIGH>";
		}

		return sAXLText;
	}
})

dmgis.object.Layer = (function () {
	this.name = "未知"; //图层名称
	this.visible = 1; //是否可见
	this.newpath = ""; //新的文件路径  newpath只支持雷达图和影象图，影象图只支持卫星文件的修改
	this.radrangle = 230; //雷达图的公里范围
	this.hdSet = null; //高亮显示地方  HighDisp[]
	this.tmset = null; //专题图条件 Tm[]
	this.GetXmlString = GetXmlString;

	function GetXmlString() {
		var sAXLText = '<LAYERDEF name="' + this.name + '" radrangle="' + this.radrangle + '"  visible="' + "1" + '" newpath="' + this.newpath + '">';

		if (this.hdSet != null) {
			var num = this.hdSet.length;
			for (var i = 0; i < num; i++) {
				sAXLText = sAXLText + this.hdSet[i].GetXmlString();
			}
		}
		if (this.tmset != null) {
			var num = this.tmset.length;
			for (var i = 0; i < num; i++) {
				sAXLText = sAXLText + this.tmset[i].GetXmlString();
			}
		}
		sAXLText = sAXLText + "</LAYERDEF>";
		return sAXLText;
	}
})

dmgis.object.LayerDisp = (function () {
	this.name = "";
	this.visible = 1;
})

dmgis.object.FeatureQueryParam = (function () {
	this.Attribute = 1; //是否有属性
	this.BeginRecord = 0; //开始记录
	this.Envelop = 1; //是否有矩形
	this.FeatureLimit = 1000; //返回记录最大数
	this.Geometry = 1; //是否有坐标
	this.GlobalEnvelope = 1; //是否有集合的外围矩形
	this.Node = 0; //节点标志
})

dmgis.object.RcoVal = (function () {
	this.fldname = ""; //字段名
	this.fldval = ""; //字段值
	this.fldtype = ""; //字段类型
})

dmgis.object.ServiceInfo = (function () {
	this.serverPath = "";
	this.prjRect = null;
	this.layers = null;
})

dmgis.object.ImgServiceParam = (function () {
	this.serverName = "世界地图"; //服务名称
	this.statesn = "-1"; //服务的密码（如果小于0为
	this.imgHig = 400; //地图宽高
	this.imgWid = 400;
	this.DispRect = new dmgis.object.Envelope(); //地图的范围
	this.layers = null; //dmgis.object.Layer[]
	this.GetXmlString = GetXmlString; //得到XML
	this.ResetService = ResetService; //通过得到的服务还原地图
	this.SetLayerVisible = SetLayerVisible; //设置一个图层显示
	this.AddLayerHDisp = AddLayerHDisp; //为一个图层添加高亮,返回高亮自己设置
	this.AddLayerTm = AddLayerTm; //为一个图层添加专题图
	this.ClearLayerHDisp = ClearLayerHDisp; //清除一个图层的高亮
	this.ClearLayerTm = ClearLayerTm; //清除一个图层的专题图
	this.SetLayerNewPath = SetLayerNewPath; //设置新的文件

	function GetXmlString() {
		var sAXLText;
		sAXLText = '<?xml version="1.0" encoding="UTF-8"?><DMGISXML version="1.1">';
		sAXLText = sAXLText + "<REQUEST>";
		sAXLText = sAXLText + '<GET_IMAGE width="' + this.imgWid + '" height="' + this.imgHig + '" ';
		sAXLText = sAXLText + 'minx="' + this.DispRect.minx + '" miny="' + this.DispRect.miny + '" maxx="' + this.DispRect.maxx + '" maxy="' + this.DispRect.maxy + '" >';
		if (this.layers != null) {
			sAXLText = sAXLText + "<LAYERLIST>";
			var num = this.layers.length;
			for (var i = 0; i < num; i++) {
				sAXLText = sAXLText + this.layers[i].GetXmlString();
			}
			sAXLText = sAXLText + "</LAYERLIST>";
		}
		sAXLText = sAXLText + "</GET_IMAGE></REQUEST></DMGISXML>";
		return sAXLText;
	}

	//还原设置  svr为DmMapServiceInfo
	function ResetService(svr) {
		if (svr == null || svr.prjRect == undefined) {
			return;
		}
		this.DispRect.minx = svr.prjRect.minx;
		this.DispRect.miny = svr.prjRect.miny;
		this.DispRect.maxx = svr.prjRect.maxx;
		this.DispRect.maxy = svr.prjRect.maxy;
		//初始化图层
		this.layers = null;
		this.layers = new Array();
		var num = svr.layers.length;

		for (var i = 0; i < num; i++) {
			this.layers.push(i);
			this.layers[i] = new dmgis.object.Layer();
			this.layers[i].name = svr.layers[i].name;
			this.layers[i].visible = svr.layers[i].visible;
		}
	}
	//设置一个图层显示
	function SetLayerVisible(layername, Is) {
		var num = this.layers.length;
		for (var i = 0; i < num; i++) {
			if (this.layers[i].name == layername) {
				this.layers[i].visible = Is;
				return true;
			}
		}
		return false;
	}
	//设置新的文件
	function SetLayerNewPath(layername, path, drangle) {
		var num = this.layers.length;
		for (var i = 0; i < num; i++) {
			if (this.layers[i].name == layername) {
				this.layers[i].newpath = path;
				if (drangle > 0) this.layers[i].radrangle = drangle;
				return true;
			}
		}
		return false;
	}
	//为一个图层添加高亮,返回高亮自己设置
	function AddLayerHDisp(layername) {
		var num = this.layers.length;
		for (var i = 0; i < num; i++) {
			if (this.layers[i].name == layername) {
				if (this.layers[i].hdSet == null) {
					this.layers[i].hdSet = new Array();
				}
				var len = this.layers[i].hdSet.length;
				this.layers[i].hdSet.push(len);

				this.layers[i].hdSet[len] = new dmgis.object.HighDisp();

				return this.layers[i].hdSet[len];
			}
		}
		return null;
	}
	//为一个图层添加专题图
	function AddLayerTm(layername) {
		var num = this.layers.length;
		for (var i = 0; i < num; i++) {
			if (this.layers[i].name == layername) {
				if (this.layers[i].tmset == null) {
					this.layers[i].tmset = new Array(); //该图层专题图数组，存放专题图信息
				}
				var len = this.layers[i].tmset.length; //多个字段专题图？
				this.layers[i].tmset.push(len);
				this.layers[i].tmset[len] = new dmgis.object.Tm(); //专题图信息
				return this.layers[i].tmset[len]; //返回专题图信息
			}
		}
		return null;
	}
	//清除一个图层的高亮
	function ClearLayerHDisp(layername) {
		var num = this.layers.length;
		for (var i = 0; i < num; i++) {
			if (this.layers[i].name == layername) {
				this.layers[i].hdSet = null;
				return true;
			}
		}
		return false;
	}
	//清除一个图层的专题图
	function ClearLayerTm(layername) {
		var num = this.layers.length;
		for (var i = 0; i < num; i++) {
			if (this.layers[i].name == layername) {
				this.layers[i].tmset = null;
				return true;
			}
		}
		return false;
	}
	//根据图层名称获取图层对象
	this.GetLayerByName = function (name) {
		for (var i = 0; i <= this.layers.length - 1; i++) {
			if (this.Layers[i].name == name) {
				return this.Layers[i];
			}
		}
	};
})

dmgis.object.FeatureServiceParam = (function () {
	this.serverName = "世界地图"; //服务名称
	this.strlayername = "行政区"; //查询的图层
	this.param = new dmgis.object.FeatureQueryParam(); //查询参数
	this.sql = new dmgis.object.SpatialQuery(); //查询条件
	this.type = 0; //查询类型0查询1索引2实体号
	this.strlist = ""; //索引号或实体号
	this.GetXmlString = GetXmlString; //得到xml
	this.SetIndexSet = SetIndexSet; //设置索引
	this.SetIdSet = SetIdSet; //设置实体

	//设置索引
	function SetIndexSet(str) {
		this.type = 1;
		this.strlist = str;
	}

	//设置实体
	function SetIdSet(str) {
		this.type = 2;
		this.strlist = str;
	}

	function GetXmlString() {
		var sAXLText;
		sAXLText = '<?xml version="1.0" encoding="UTF-8"?><DMGISXML version="1.1">';
		sAXLText = sAXLText + "<REQUEST>";
		sAXLText =
			sAXLText + '<GET_FEATURES  attributes="' + this.param.Attribute + '" beginrecord="' + this.param.BeginRecord + '" envelope="' + this.param.Envelop + '" featurelimit="' + this.param.FeatureLimit + '" geometry="' + this.param.Geometry + '" globalenvelope="' + this.param.GlobalEnvelope + '"';
		sAXLText = sAXLText + ' layername="' + this.strlayername + '" nodflag="' + this.param.Node + '">';
		sAXLText = sAXLText + '<GETOBJ type="' + this.type + '">';
		if (this.type == 1) {
			sAXLText = sAXLText + '<INDEXLIST list="' + this.strlist + '"/>';
		} else if (this.type == 2) {
			sAXLText = sAXLText + '<IDLIST list="' + this.strlist + '"/>';
		} else if (this.type == 0) {
			sAXLText = sAXLText + this.sql.GetXmlString();
		}
		sAXLText = sAXLText + "</GETOBJ>";
		sAXLText = sAXLText + "</GET_FEATURES>";
		sAXLText = sAXLText + "</REQUEST>";
		sAXLText = sAXLText + "</DMGISXML>";
		return sAXLText;
	}
})

dmgis.object.BufferServiceParam = (function () {
	this.serverName = "世界地图"; //服务名称
	this.statesn = "-1"; //服务的密码（如果小于0为无态）
	this.strlayername = "行政区"; //查询的图层
	this.type = 0; //类型 0为索引1为实体号
	this.no = 0; //索引或实体号
	this.blc = 20000.0; //缓冲范围
	this.isNod = 0; //是否节点
	this.GetXmlString = GetXmlString;

	function GetXmlString() {
		var sAXLText;
		sAXLText = '<?xml version="1.0" encoding="UTF-8"?><DMGISXML version="1.1">';
		sAXLText = sAXLText + "<REQUEST>";
		sAXLText = sAXLText + "<GET_BUFFER";
		sAXLText = sAXLText + ' type="' + this.type + '" nodflag="' + this.isNod + '" layername="' + this.strlayername + '"';
		sAXLText = sAXLText + ' objindex="' + this.no + '"';
		sAXLText = sAXLText + ' bufferblc="' + this.blc + '"/>';
		sAXLText = sAXLText + "</REQUEST>";
		sAXLText = sAXLText + "</DMGISXML>";
		return sAXLText;
	}
})

dmgis.object.PathServiceParam = (function () {
	this.serverName = "世界地图"; //服务名称
	this.statesn = "-1"; //服务的密码（如果小于0为无态）
	this.strlayername = "行政区"; //查询的图层
	this.type = 0; //类型 0点１号２索３公交
	this.ipos = "12658733.54958 3287847.75389"; //开始节点  公交ipos和epos为站点名 点为点坐标(33 44)
	this.epos = "12683917.90057 3273792.40307"; //结束节点
	this.ex = 1565.9810040136717; //路径分析误差
	this.GetXmlString = GetXmlString; //得到xml
	function GetXmlString() {
		var sAXLText;
		sAXLText = '<?xml version="1.0" encoding="UTF-8"?><DMGISXML version="1.1">';
		sAXLText = sAXLText + "<REQUEST>";
		sAXLText = sAXLText + "<GET_PATH";
		sAXLText = sAXLText + ' type="' + this.type + '" layername="' + this.strlayername + '"';
		sAXLText = sAXLText + ' ipos="' + this.ipos + '"';
		sAXLText = sAXLText + ' epos="' + this.epos + '"';
		sAXLText = sAXLText + ' wx="' + this.ex + '"/>';
		sAXLText = sAXLText + "</REQUEST>";
		sAXLText = sAXLText + "</DMGISXML>";
		return sAXLText;
	}
})

dmgis.object.DmRcoVal = (function (fldname, fldval) {
	this.fldname = fldname
	this.fldval = fldval
})

dmgis.object.BuildServiceParam = (function () {
	this.serverName = "世界地图"; //服务名称
	this.statesn = "-1"; //服务的密码（如果小于0为无态）
	this.strlayername = "主要城市"; //查询的图层
	this.type = 0; //0 为 添加实体  1为删除实体  2为修改实体图形坐标  3为修改修改属性 4为保存图层
	this.index = 0;
	this.strPos = "";
	this.rco = null; //DmRcoVal的集合
	this.GetXmlString = GetXmlString;

	function GetXmlString() {
		var sAXLText;
		sAXLText = '<?xml version="1.0" encoding="UTF-8"?><DMGISXML version="1.1">';
		sAXLText = sAXLText + "<REQUEST>";
		sAXLText = sAXLText + "<Build ";
		sAXLText = sAXLText + 'type ="' + this.type + '" index="' + this.index + '" cor="' + this.strPos + '" layername="' + this.strlayername + '">';
		if (this.rco != null) {
			var num = this.rco.length;
			for (var i = 0; i < num; i++) {
				sAXLText = sAXLText + '<Field name="' + this.rco[i].fldname + '" val="' + this.rco[i].fldval + '" />';
			}
		}
		sAXLText = sAXLText + "</Build>";
		sAXLText = sAXLText + "</REQUEST>";
		sAXLText = sAXLText + "</DMGISXML>";
		return sAXLText;
	}
})

dmgis.object.ImageInfo = (function () {
	this.imgUrl = ""; //此属性图片的网络位置
	this.imgPath = ""; //此属性图片的本地位置
	this.extent = new dmgis.object.Envelope(); //实际的地理范围
})

dmgis.object.WorkObj = (function () {
	this.id = 0; //实体号
	this.index = 0; //索引号
	this.type = 8; //坐标类型 (0点1线面2复合体)
	this.strPnt = null; //点坐标
	this.strCor = null; //坐标 (线区和复合体线坐标）
	this.strRng = null; //坐标（复合替面坐标）
	this.env = null; //范围
	this.rec = null; //属性信息DmRcoVal集合
})

dmgis.object.FeatureInfo = (function () {
	this.objset = null; //实体集合
	this.genv = null; //范围
	this.znum = null; //这次查询总的实体数
	this.isMore = null; //是否还有数据
})

dmgis.object.BufferInfo = (function () {
	this.strPos = null; //缓冲的坐标
	this.env = new dmgis.object.Envelope(); //范围
})

dmgis.object.PathInfo = (function () {
	this.strPos = ""; //坐标
	this.strSta = ""; //站点
	this.strLin = ""; //线路
	this.ll = 0; //长度
	this.env = new dmgis.object.Envelope(); //范围
})

dmgis.object.LengthPoint = (function (_x, _y, _distance) {
	this.x = _x;
	this.y = _y;
	this.Distance = _distance;
})

dmgis.object.GridRequestPar = (function (_url, _data, _DataTemplate, _TagTemplate, _success) {
	this.url = _url;
	this.data = _data;
	this.DataTemplate = _DataTemplate;
	this.TagTemplate = _TagTemplate;
	this.success = _success;
})

dmgis.tool = dmgis.tool ? dmgis.tool : {};
dmgis.tool = (function () { })

dmgis.tool.Min = (function (val1, val2) {
	if (val1 > val2) return val2;
	else return val1;
})

dmgis.tool.Max = (function (val1, val2) {
	if (val1 < val2) return val2;
	else return val1;
})

dmgis.tool.Intersect = (function (srect1, srect2) {
	var dt1 = new dmgis.object.Point(srect1.xmin, srect1.ymin);
	if (dmgis.tool.DotInRect(dt1, srect2))
		return true;
	var dt2 = new dmgis.object.Point(srect1.xmin, srect1.ymax);
	if (dmgis.tool.DotInRect(dt2, srect2))
		return true;
	var dt3 = new dmgis.object.Point(srect1.xmax, srect1.ymax);
	if (dmgis.tool.DotInRect(dt3, srect2))
		return true;
	var dt4 = new dmgis.object.Point(srect1.xmax, srect1.ymin);
	if (dmgis.tool.DotInRect(dt4, srect2))
		return true;
	return false;
})

dmgis.tool.DotInRect = (function (pnt, rect) {
	if (pnt.x < rect.xmin)
		return false;
	if (pnt.x > rect.xmax)
		return false;
	if (pnt.y < rect.ymin)
		return false;
	if (pnt.y > rect.ymax)
		return false;
	return true;
})

dmgis.tool.AndRect = (function (srect1, srect2) {
	var ds = new dmgis.object.Envelope();
	ds.minx = srect1.minx > srect2.minx ? srect1.minx : srect2.minx;
	ds.miny = srect1.miny > srect2.miny ? srect1.miny : srect2.miny;
	ds.maxx = srect1.maxx < srect2.maxx ? srect1.maxx : srect2.maxx;
	ds.maxy = srect1.maxy < srect2.maxy ? srect1.maxy : srect2.maxy;
	return ds;
})

dmgis.tool.DotInPolygon = (function (PQarray, XDot, YDot) {
	var CheckFlg = false;
	var cout = 0;
	if (PQarray[PQarray.length - 1].x == XDot && PQarray[PQarray.length - 1].y == YDot) {
		CheckFlg = true;
	} else {
		if ((PQarray[PQarray.length - 1].y > YDot && PQarray[0].y < YDot) || (PQarray[PQarray.length - 1].y < YDot && PQarray[0].y > YDot)) {
			var tmpX = parseInt((PQarray[0].x * YDot + PQarray[PQarray.length - 1].x * PQarray[0].y - PQarray[PQarray.length - 1].x * YDot - PQarray[0].x * PQarray[PQarray.length - 1].y) / (PQarray[0].y - PQarray[PQarray.length - 1].y));
			if (tmpX == XDot) CheckFlg = true;
			else if (tmpX > XDot) cout++;
		}
	}
	if (!CheckFlg) {
		for (var i = 0; i < PQarray.length - 1; i++) {
			if (PQarray[i].x == XDot && PQarray[i].y == YDot) {
				CheckFlg = true;
				break;
			} else {
				if ((PQarray[i].y > YDot && PQarray[i + 1].y < YDot) || (PQarray[i].y < YDot && PQarray[i + 1].y > YDot)) {
					var tmpX = parseInt((PQarray[i].x * YDot + PQarray[i + 1].x * PQarray[i].y - PQarray[i + 1].x * YDot - PQarray[i].x * PQarray[i + 1].y) / (PQarray[i].y - PQarray[i + 1].y));
					if (tmpX == XDot) {
						CheckFlg = true;
						break;
					} else if (tmpX > XDot) cout++;
				}
			}
		}
	}
	if (!CheckFlg && cout % 2 == 1) CheckFlg = true;
	return CheckFlg;
})

dmgis.tool.GetRectCenter = (function (startPoint, endPoint) {
	return new dmgis.object.Point((endPoint.x + startPoint.x) / 2, (endPoint.y + startPoint.y) / 2);
})

dmgis.tool.Rad = (function (d) {
	return (d * Math.PI) / 180.0;
})

dmgis.tool.GetDistance = (function (Point1, Point2) {
	var radLat1 = rad(Point1.y);
	var radLat2 = rad(Point2.y);
	var a = radLat1 - radLat2;
	var b = rad(Point1.x) - rad(Point2.x);
	var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
	s = s * EARTH_RADIUS;
	s = Math.round(s * 10000) / 10000;
	return s;
})

dmgis.tool.GetLengthBy2Pnt = (function (startPoint, endPoint) {
	if (startPoint.x < 180 && startPoint.x > 0) {
		return GetDistance(startPoint, endPoint);
	}
	return Math.sqrt((endPoint.x - startPoint.x) * (endPoint.x - startPoint.x) + (endPoint.y - startPoint.y) * (endPoint.y - startPoint.y));
})

dmgis.tool.GetLengthUnit = (function (CoorLength) {
	if (CoorLength < 1000) {
		return CoorLength.toFixed(1) + "</font>米";
	} else {
		return (CoorLength / 1000).toFixed(1) + "</font>公里";
	}
})

dmgis.tool.GetAreaUnit = (function (CoorLength) {
	if (CoorLength < 1000000) {
		return CoorLength.toFixed(1) + "</font>平方米";
	} else if (CoorLength >= 1000000 && CoorLength < 10000000000) {
		return (CoorLength / 1000000).toFixed(1) + "</font>平方公里";
	} else {
		return (CoorLength / 10000000000).toFixed(1) + "</font>万平方公里";
	}
})

dmgis.tool.CalculateArea = (function (PointArray) {
	var area = 0;
	var i, j;
	var xjyi, xiyj;
	var xydiff;
	j = PointArray.length - 1;
	for (i = 0; i <= PointArray.length - 1; i++) {
		xiyj = PointArray[i].x * PointArray[j].y;
		xjyi = PointArray[j].x * PointArray[i].y;
		xydiff = xiyj - xjyi;
		area += xydiff;
		j = i;
	}
	area = Math.abs(area / 2);
	if (PointArray[0].x < 180 && PointArray[0].x > 0) {
		area = area * 111000 * 111000;
	}
	return area;
})

dmgis.tool.Rot = (function (x, y, angle) {
	var a = (angle * -3.1415926) / 180;
	var ix = x * Math.cos(a) - y * Math.sin(a);
	var iy = x * Math.sin(a) + y * Math.cos(a);
	return [parseInt(ix), parseInt(iy)];
})

dmgis.tool.GetRectMinMax = (function (pointArray) {
	var rect = new dmgis.object.Envelope();
	rect.minx = pointArray[0].x;
	rect.maxx = pointArray[0].x;
	rect.miny = pointArray[0].y;
	rect.maxy = pointArray[0].y;
	for (var i = 0; i <= pointArray.length - 1; i++) {
		if (pointArray[i].x < rect.minx) {
			rect.minx = pointArray[i].x;
		}

		if (pointArray[i].x > rect.maxx) {
			rect.maxx = pointArray[i].x;
		}

		if (pointArray[i].y < rect.miny) {
			rect.miny = pointArray[i].y;
		}

		if (pointArray[i].y > rect.maxy) {
			rect.maxy = pointArray[i].y;
		}
	}
	return rect;
})

dmgis.tool.Curve = (function (xq, m) {
	//xq为坐标二维数组,m为已知点个数.
	var resultArray = new Array();
	var i,
		j,
		k = 20;
	var lx1, ly2; //曲线点坐标
	var t0, t1, t2, t3;
	lx1 = (xq[0].x + 4.0 * xq[1].x + xq[2].x) / xq.length;
	ly1 = (xq[0].y + 4.0 * xq[1].y + xq[2].y) / xq.length;
	for (i = 1; i < m - 2; i++) {
		for (j = 0; j <= k; j++) {
			t3 = (1.0 * j) / k;
			t0 = 1 - t3;
			t0 = (t0 * t0 * t0) / 6.0;
			t1 = ((3.0 * t3 - 6.0) * t3 * t3 + 4.0) / 6.0;
			t2 = (((3 - 3 * t3) * t3 + 3) * t3 + 1) / 6.0;
			t3 = 1.0 - t0 - t1 - t2;
			lx1 = xq[i - 1].x * t0 + xq[i].x * t1 + xq[i + 1].x * t2 + xq[i + 2].x * t3;
			ly1 = xq[i - 1].y * t0 + xq[i].y * t1 + xq[i + 1].y * t2 + xq[i + 2].y * t3;
			resultArray.push(new dmgis.object.Envelope(lx1, ly1));
		}
	}
	return resultArray;
})

dmgis.tool.CurvePnt = (function (p) {
	//p为已知点,已知点有N+3个
	var q = new Array();
	var r = new Array();
	p.push(p[0]);
	p.push(p[1]);
	p.push(p[2]);
	var a = 0,
		b = 0,
		c = 0,
		d = 0,
		k = 0,
		s1 = 0,
		s2 = 0;
	var x = new Array();
	var y = new Array();
	var i, color;
	for (i = 0; i < p.length - 3; i++) {
		x[i] = p[i].x;
		y[i] = p[i].y;
		a = a + x[i];
		b = b + y[i];
	}
	a = a / (p.length - 3); //a,b 为重心 N为顶点个数
	b = b / (p.length - 3);
	c = (x[0] + 4 * x[1] + x[2]) / 6; //c,d为点X[1]Y[1]所对应的缩小点
	d = (y[0] + 4 * y[1] + y[2]) / 6;
	s1 = (x[1] - a) * (x[1] - a) + (y[1] - b) * (y[1] - b);
	s1 = Math.sqrt(s1);
	s2 = (c - a) * (c - a) + (d - b) * (d - b);
	s2 = Math.sqrt(s2);
	k = s1 / s2;
	x[p.length - 3 + 2] = (p[p.length - 3 + 2][0] + p[3].x) / 2;
	y[p.length - 3 + 2] = (p[p.length - 3 + 2][1] + p[3].y) / 2;
	for (i = 0; i < p.length - 3 + 2; i++) {
		x[i] = (p[i].x + p[i + 1].x) / 2; //x[i]y[i]为p的中点构成的多边形
		y[i] = (p[i].y + p[i + 1].y) / 2;
	}

	for (i = 0; i < p.length - 3 + 3; i++) {
		r[i] = new dmgis.object.Envelope();
		r[i].x = k * (p[i].x - a) + a;
		r[i].y = k * (p[i].y - b) + b;
	}
	return r;
})

dmgis.tool.ArrayToString = (function (PointArray) {
	var resultStr = "";
	for (var i = 0; i <= PointArray.length - 1; i++) {
		resultStr += PointArray[i].x + " " + PointArray[i].y + ";";
	}
	resultStr = resultStr + PointArray[0].x + " " + PointArray[0].y;
	return resultStr;
})

dmgis.tool.StringToArray = (function (strPoint) {
	var result = new Array();
	var row = strPoint.split(";");
	for (var i = 0; i <= row.length - 1; i++) {
		result.push(new dmgis.object.Point(parseFloat(row[i].split(" ")[0]), parseFloat(row[i].split(" ")[1])));
	}
	return result;
})

dmgis.tool.StringToArray2 = (function (strPoint, flag) {
	var result = new Array();
	var row = strPoint.split(flag);
	for (var i = 0; i <= row.length - 1; i++) {
		result.push(new dmgis.object.Point(parseFloat(row[i].split(" ")[0]), parseFloat(row[i].split(" ")[1])));
	}
	return result;
})

dmgis.tool.transWin32ColorToHtml = (function (color) {
	var htmlColor = "#ffffff";
	color = parseInt(color);
	try {
		var r = (color & 255).toString(16);
		var g = ((color >> 8) & 255).toString(16);
		var b = ((color >> 16) & 255).toString(16);
		htmlColor = "#" + (r.length < 2 ? "0" + r : r) + (g.length < 2 ? "0" + g : g) + (b.length < 2 ? "0" + b : b);
	} catch (e) {
		this.$message.error(e.message);
	}
	return htmlColor;
})

//递归获取元素的的坐标X
dmgis.tool.getElementOffsetX = (function (obj) {
	if ($(obj).parent().length != 0) {
		return obj.offsetLeft + dmgis.tool.getElementOffsetX($(obj).parent()[0]);
	} else {
		if (obj.offsetLeft == undefined) {
			return 0;
		}
		return obj.offsetLeft;
	}
})

//递归获取元素的的坐标Y
dmgis.tool.getElementOffsetY = (function (obj) {
	if ($(obj).parent().length != 0) {
		return obj.offsetTop + dmgis.tool.getElementOffsetY($(obj).parent()[0]);
	} else {
		if (obj.offsetTop == undefined) {
			return 0;
		}
		return obj.offsetTop;
	}
})

//获取竖向滚动条滚动数
dmgis.tool.getBodyScrollTop = (function (obj) {
	if ("pageYOffset" in window) {
		return window.pageYOffset;
	} else if (document.compatMode === "BackCompat") {
		return document.body.scrollTop;
	} else {
		return document.documentElement.scrollTop;
	}
})

//获取横向滚动条滚动数
dmgis.tool.getBodyScrollLeft = (function (obj) {
	if ("pageXOffset" in window) {
		return window.pageXOffset;
	} else if (document.compatMode === "BackCompat") {
		return document.body.scrollLeft;
	} else {
		return document.documentElement.scrollLeft;
	}
})

dmgis.tool.DptoSpOL = (function (map, x, y) {
	var ObjCoor = new Array();
	ObjCoor[0] = x;
	ObjCoor[1] = y;
	var ScreenCoor = map.getPixelFromCoordinate(ObjCoor);
	var SpCoor = new dmgis.object.Point(ScreenCoor[0], ScreenCoor[1]);
	return SpCoor;
})

dmgis.tool.DptoSpCE = function (map, x, y) {
	var scratch = new Cesium.Cartesian2();
	var xx = parseFloat(x);
	var yy = parseFloat(y);
	try {
		if (xx == undefined || yy == undefined || isNaN(xx) || isNaN(yy))
			return null;
		var position = Cesium.Cartesian3.fromDegrees(xx, yy);
		var canvasPosition = map.scene.cartesianToCanvasCoordinates(position, scratch);
		if (Cesium.defined(canvasPosition)) {
			return new dmgis.object.Point(canvasPosition.x, canvasPosition.y);
		} else {
			return null;
		}
	} catch (e) {
		// TODO: handle exception
		return null;
	}
}

dmgis.tool.GetWinRect = (function (viewer) {
	// 范围对象
	var extent;
	let extend = viewer.camera.computeViewRectangle();
	if (typeof extend === "undefined") {
		//2D下会可能拾取不到坐标，extend返回undefined,所以做以下转换
		let canvas = viewer.scene.canvas;
		let upperLeft = new Cesium.Cartesian2(0, 0);//canvas左上角坐标转2d坐标
		let lowerRight = new Cesium.Cartesian2(
			canvas.clientWidth,
			canvas.clientHeight
		);//canvas右下角坐标转2d坐标

		let ellipsoid = viewer.scene.globe.ellipsoid;
		let upperLeft3 = viewer.camera.pickEllipsoid(
			upperLeft,
			ellipsoid
		);//2D转3D世界坐标

		let lowerRight3 = viewer.camera.pickEllipsoid(
			lowerRight,
			ellipsoid
		);//2D转3D世界坐标

		let upperLeftCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(
			upperLeft3
		);//3D世界坐标转弧度
		let lowerRightCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(
			lowerRight3
		);//3D世界坐标转弧度

		let minx = Cesium.Math.toDegrees(upperLeftCartographic.longitude);//弧度转经纬度
		let maxx = Cesium.Math.toDegrees(lowerRightCartographic.longitude);//弧度转经纬度

		let miny = Cesium.Math.toDegrees(lowerRightCartographic.latitude);//弧度转经纬度
		let maxy = Cesium.Math.toDegrees(upperLeftCartographic.latitude);//弧度转经纬度
		extent = new dmgis.object.Envelope();
		extent.minx = minx;
		extent.maxx = maxx;
		extent.miny = miny;
		extent.maxy = maxy;
	} else {
		//3D获取方式
		extent = new dmgis.object.Envelope();
		extent.maxx = Cesium.Math.toDegrees(extend.east);
		extent.maxy = Cesium.Math.toDegrees(extend.north);

		extent.minx = Cesium.Math.toDegrees(extend.west);
		extent.miny = Cesium.Math.toDegrees(extend.south);
	}
	return extent;//返回屏幕所在经纬度范围

})



dmgis.service = dmgis.service ? dmgis.service : {};
dmgis.service = (function () { })

dmgis.service.GetServices = (function (response) {
	try {
		var axlResponse = response; //LoadXml(response);
		var list = null;
		if (axlResponse.getElementsByTagName("Services").length >= 1) {
			list = axlResponse.getElementsByTagName("Services");
			var layerList = null;
			if (axlResponse.getElementsByTagName("Service").length >= 1) {
				layerList = axlResponse.getElementsByTagName("Service");
				var strservice = new Array();
				for (var i = 0; i < layerList.length; i++) {
					strservice.push(i);
					strservice[i] = layerList[i].attributes.getNamedItem("name").nodeValue;
				}
				return strservice;
			}
		}
		return null;
	} catch (e) {
		return null;
	}
})

dmgis.service.GetProjServers = (function (response) {
	try {
		var axlResponse = response;
		var list = null;
		var serverInfo = null;
		if (axlResponse.getElementsByTagName("SERVER").length >= 1) {
			list = axlResponse.getElementsByTagName("SERVER");
			var serverInfo = new dmgis.object.ServiceInfo();
			serverInfo.serverPath = list[0].attributes.getNamedItem("prjname").nodeValue;
			serverInfo.prjRect = new dmgis.object.Envelope();
			serverInfo.prjRect.miny = parseFloat(list[0].attributes.getNamedItem("miny").nodeValue);
			serverInfo.prjRect.minx = parseFloat(list[0].attributes.getNamedItem("minx").nodeValue);
			serverInfo.prjRect.maxx = parseFloat(list[0].attributes.getNamedItem("maxx").nodeValue);
			serverInfo.prjRect.maxy = parseFloat(list[0].attributes.getNamedItem("maxy").nodeValue);
			var layerList = null;
			if (axlResponse.getElementsByTagName("LAYER").length >= 1) {
				layerList = axlResponse.getElementsByTagName("LAYER");
				serverInfo.layers = new Array();
				for (var i = 0; i < layerList.length; i++) {
					serverInfo.layers.push(i);
					serverInfo.layers[i] = new dmgis.object.LayerDisp();
					serverInfo.layers[i].name = layerList[i].attributes.getNamedItem("name").nodeValue;
					serverInfo.layers[i].visible = parseInt(layerList[i].attributes.getNamedItem("visible").nodeValue);
				}
			}
		}
		return serverInfo;
	} catch (e) {
		this.$message.error(e);
		return null;
	}
})

dmgis.service.GetImageInfo = (function (response) {
	try {
		var axlResponse = response;
		var inf = new dmgis.object.ImageInfo();
		if (axlResponse.getElementsByTagName("ENVELOPE").length == 1) {
			var noderefput = axlResponse.getElementsByTagName("ENVELOPE");
			inf.extent.minx = parseFloat(noderefput[0].attributes.getNamedItem("minx").nodeValue);
			inf.extent.miny = parseFloat(noderefput[0].attributes.getNamedItem("miny").nodeValue);
			inf.extent.maxx = parseFloat(noderefput[0].attributes.getNamedItem("maxx").nodeValue);
			inf.extent.maxy = parseFloat(noderefput[0].attributes.getNamedItem("maxy").nodeValue);
		}
		if (axlResponse.getElementsByTagName("OUTPUT").length == 1) {
			var noderefput = axlResponse.getElementsByTagName("OUTPUT");
			inf.imgUrl = noderefput[0].attributes.getNamedItem("url").nodeValue;
			inf.imgPath = noderefput[0].attributes.getNamedItem("file").nodeValue;
			return inf;
		}
		return null;
	} catch (e) {
		return null;
	}
})

dmgis.service.GetFeatureInfo = (function (response) {
	try {
		var axlResponse = response;
		if (axlResponse.getElementsByTagName("FEATURES").length == 1) {
			//得到实体
			var noderefput = axlResponse.getElementsByTagName("FEATURES");
			if (noderefput.length > 0) {
				var feature = new dmgis.object.FeatureInfo();
				//得到实体的节点
				var node = noderefput[0];
				//得到实体的子节点
				var nodelist = node.childNodes;
				var num = nodelist.length;
				if (num > 0) {
					//得到外围矩形

					if (nodelist[num - 1].nodeName == "ENVELOPE") {
						num = num - 1;
						feature.genv = new dmgis.object.Envelope();
						feature.genv.minx = parseFloat(nodelist[num].attributes.getNamedItem("minx").nodeValue);
						feature.genv.miny = parseFloat(nodelist[num].attributes.getNamedItem("miny").nodeValue);
						feature.genv.maxx = parseFloat(nodelist[num].attributes.getNamedItem("maxx").nodeValue);
						feature.genv.maxy = parseFloat(nodelist[num].attributes.getNamedItem("maxy").nodeValue);
					}

					//得到总数
					feature.znum = parseInt(nodelist[num - 1].attributes.getNamedItem("count").nodeValue);
					feature.isMore = parseInt(nodelist[num - 1].attributes.getNamedItem("hasmore").nodeValue);

					num = num - 1;
					if (num > 0) {
						feature.objset = new Array();
						for (var i = 0; i < num; i++) {
							feature.objset.push(i);
							feature.objset[i] = new dmgis.object.WorkObj();
							var node1 = nodelist[i];
							feature.objset[i].id = parseInt(node1.attributes.getNamedItem("id").nodeValue);
							feature.objset[i].index = parseInt(node1.attributes.getNamedItem("index").nodeValue);
							var nodelist1 = node1.childNodes;
							for (var j = 0; j < nodelist1.length; j++) {
								//外围矩形
								if (nodelist1[j].nodeName == "ENVELOPE") {
									feature.objset[i].env = new dmgis.object.Envelope();
									feature.objset[i].env.minx = parseFloat(nodelist1[j].attributes.getNamedItem("minx").nodeValue);
									feature.objset[i].env.miny = parseFloat(nodelist1[j].attributes.getNamedItem("miny").nodeValue);
									feature.objset[i].env.maxx = parseFloat(nodelist1[j].attributes.getNamedItem("maxx").nodeValue);
									feature.objset[i].env.maxy = parseFloat(nodelist1[j].attributes.getNamedItem("maxy").nodeValue);
								}
								//属性
								if (nodelist1[j].nodeName == "FIELDS") {
									var node2 = nodelist1[j];
									var fnum = node2.attributes.length;
									feature.objset[i].rec = new Array();
									for (var z = 0; z < fnum; z++) {
										feature.objset[i].rec.push(z);
										feature.objset[i].rec[z] = new dmgis.object.RcoVal();
										feature.objset[i].rec[z].fldname = node2.attributes.item(z).nodeName;
										feature.objset[i].rec[z].fldval = node2.attributes.item(z).nodeValue;
									}
								}
								//坐标
								if (nodelist1[j].nodeName == "POS") {
									var node3 = nodelist1[j];
									var type = parseInt(node3.attributes.getNamedItem("type").nodeValue);
									feature.objset[i].type = type;
									if (type == 0) {
										feature.objset[i].strPnt = node3.attributes.getNamedItem("pnt").nodeValue;
									} else if (type == 1) {
										feature.objset[i].strCor = node3.attributes.getNamedItem("cod").nodeValue;
									} else if (type == 2) {
										feature.objset[i].strPnt = node3.attributes.getNamedItem("pnt").nodeValue;
										feature.objset[i].strCor = node3.attributes.getNamedItem("cod").nodeValue;
										feature.objset[i].strRng = node3.attributes.getNamedItem("rng").nodeValue;
									}
								}
							}
						}
					}
				}
				return feature;
			}
		}
		return null;
	} catch (e) {
		return null;
	}
})

dmgis.service.GetBufferInfo = (function (response) {
	try {
		var axlResponse = response;
		var buffer = null;
		if (axlResponse.getElementsByTagName("ENVELOPE").length == 1) {
			buffer = new dmgis.object.BufferInfo();
			var noderefput = axlResponse.getElementsByTagName("ENVELOPE");
			buffer.env.minx = parseFloat(noderefput[0].attributes.getNamedItem("minx").nodeValue);
			buffer.env.miny = parseFloat(noderefput[0].attributes.getNamedItem("miny").nodeValue);
			buffer.env.maxx = parseFloat(noderefput[0].attributes.getNamedItem("maxx").nodeValue);
			buffer.env.maxy = parseFloat(noderefput[0].attributes.getNamedItem("maxy").nodeValue);
		}
		if (axlResponse.getElementsByTagName("POLYGON").length == 1) {
			var noderefput = axlResponse.getElementsByTagName("POLYGON");
			buffer.strPos = noderefput[0].attributes.getNamedItem("coords").nodeValue;
		}
		return buffer;
	} catch (e) {
		return null;
	}
})

dmgis.service.GetPathInfo = (function (response) {
	try {
		var axlResponse = response;
		var path = null;
		if (axlResponse.getElementsByTagName("ENVELOPE").length == 1) {
			path = new dmgis.object.PathInfo();
			var noderefput = axlResponse.getElementsByTagName("ENVELOPE");
			path.env.minx = parseFloat(noderefput[0].attributes.getNamedItem("minx").nodeValue);
			path.env.miny = parseFloat(noderefput[0].attributes.getNamedItem("miny").nodeValue);
			path.env.maxx = parseFloat(noderefput[0].attributes.getNamedItem("maxx").nodeValue);
			path.env.maxy = parseFloat(noderefput[0].attributes.getNamedItem("maxy").nodeValue);
		}
		if (axlResponse.getElementsByTagName("PATH").length == 1) {
			var noderefput = axlResponse.getElementsByTagName("PATH");
			path.strPos = noderefput[0].attributes.getNamedItem("coords").nodeValue;
			path.ll = parseInt(noderefput[0].attributes.getNamedItem("dis").nodeValue);
			path.strLin = noderefput[0].attributes.getNamedItem("nodlist").nodeValue;
			path.strSta = noderefput[0].attributes.getNamedItem("arclist").nodeValue;
		}
		return path;
	} catch (e) {
		Console.Write(ex.Message);
		return null;
	}
})

dmgis.service.GetBuildInfo = (function (response) {
	try {
		var axlResponse = response;
		var builfinfo = null;
		if (axlResponse.getElementsByTagName("OBJ").length == 1) {
			builfinfo = new dmgis.object.WorkObj();
			//得到实体
			var noderefput = axlResponse.getElementsByTagName("OBJ");
			if (noderefput.length > 0) {
				//得到实体的节点
				var node = noderefput[0];
				if (parseInt(node.attributes.getNamedItem("SC").nodeValue) == 1) {
					builfinfo.index = parseInt(node.attributes.getNamedItem("index").nodeValue);
				}
			}
			return builfinfo;
		}
		return null;
	} catch (e) {
		return null;
	}
})


dmgis.service.GetWMSFeatureInfo = (function (response) {
	try {
		var axlResponse = response;
		if (axlResponse.getElementsByTagName("Layers").length == 1) {//Layers
			//得到图层
			var noderefput = axlResponse.getElementsByTagName("Layer");
			if (noderefput.length > 0) {
				for (var k = 0; k < noderefput.length; k++) {
					var nodelayer = noderefput[k];
					var layerName = nodelayer.attributes.getNamedItem("name").nodeValue


					var featurenodes = nodelayer.getElementsByTagName("Feature");

					var feature = new dmgis.object.FeatureInfo();
					if (featurenodes.length > 0) {
						feature.objset = new Array();
						for (var kk = 0; kk < featurenodes.length; kk++) {
							feature.objset.push(kk);
							feature.objset[kk] = new dmgis.object.WorkObj();
							var featurenode = featurenodes[kk];
							var fnum = featurenode.attributes.length;
							feature.objset[kk].rec = new Array();
							for (var z = 0; z < fnum; z++) {
								feature.objset[kk].rec.push(z);
								feature.objset[kk].rec[z] = new dmgis.object.RcoVal();
								feature.objset[kk].rec[z].fldname = featurenode.attributes.item(z).nodeName;
								feature.objset[kk].rec[z].fldval = featurenode.attributes.item(z).nodeValue;
							}
						}
					}
					return feature;
				}
			}
		}
		return null;
	} catch (e) {
		return null;
	}
})


dmgis.service.GetWFSDescribeFeatureInfo = (function (response) {
	try {
		var axlResponse = response;
		if (axlResponse.getElementsByTagName("xsd:schema").length == 1) {//xsd:schema
			var feature = new dmgis.object.FeatureInfo();

			var sequences = axlResponse.getElementsByTagName("xsd:sequence");

			var count = sequences.length;
			if (count == 1) {
				count = 0;
				feature.objset = new Array();
				feature.objset.push(count);
				feature.objset[count] = new dmgis.object.WorkObj();
				feature.objset[count].rec = new Array();
				//得到图层
				var elements = sequences[0].getElementsByTagName("xsd:element");
				if (elements.length > 0) {
					feature.objset[count].rec = new Array();
					for (var k = 0; k < elements.length; k++) {
						var featurenode = elements[k];
						feature.objset[count].rec.push(k);
						feature.objset[count].rec[k] = new dmgis.object.RcoVal();
						feature.objset[count].rec[k].fldname = featurenode.attributes.getNamedItem("name").nodeValue;
						feature.objset[count].rec[k].fldtype = featurenode.attributes.getNamedItem("type").nodeValue;
					}
					return feature;
				}
			}
		}
		return null;
	} catch (e) {
		return null;
	}
})

dmgis.service.GetWFSFeatureInfo = (function (response, serlayname) {
	try {
		var axlResponse = response;
		if (axlResponse.getElementsByTagName("wfs:FeatureCollection").length == 1) {//xsd:schema
			var feature = new dmgis.object.FeatureInfo();

			var sequences = axlResponse.getElementsByTagName(serlayname);

			var num = sequences.length;
			feature.objset = new Array();
			for (var i = 0; i < num; i++) {
				feature.objset.push(i);
				feature.objset[i] = new dmgis.object.WorkObj();
				feature.objset[i].rec = new Array();
				var elements = sequences[i].children;
				if (elements.length > 0) {
					feature.objset[i].rec = new Array();
					for (var k = 0; k < elements.length; k++) {
						var featurenode = elements[k];
						feature.objset[i].rec.push(k);
						feature.objset[i].rec[k] = new dmgis.object.RcoVal();
						feature.objset[i].rec[k].fldname = featurenode.tagName.split(":")[1];
						feature.objset[i].rec[k].fldval = featurenode.innerHTML;
					}
				}
			}
			return feature;
		}
		return null;
	} catch (e) {
		return null;
	}
})
